// user.js 作用是存放 和用户相关的请求
// 登录、注册、更换头像、重置密码............

import request from '@/utils/request'

// 注册的请求
export const regAPI = obj => {
  // obj = { username: '', password: '', repassword: '' }
  return request.post('/api/reg', obj)
}
// 登录的请求
export const loginAPI = obj => {
  return request.post('/api/login', obj)
}
export const getUserAPI = () => {
  return request.get('/my/userinfo')
}
// 更新用户数据
export const updateUserAPI = data => {
  // return request.put('/my/userinfo', 请求体)
  return request.put('/my/userinfo', data)
}
export const updatePwdAPI = data => {
  // return request.put('/my/userinfo', 请求体)
  return request.patch('/my/updatepwd', data)
}
// 更换头像
export const uploadAPI = base64 => {
  // return request.put('/my/userinfo', 请求体)
  return request.patch('/my/update/avatar', { avatar: base64 })
}
